package com.orangelife.service.feeDetail.impl;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.annotation.Resource;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.stereotype.Service;

import com.orangelife.exception.AppBizException;
import com.orangelife.service.Importlogs.QiniuUtils;
import com.orangelife.service.PropFeeType.IPropFeeTypeService;
import com.orangelife.service.feeDetail.IFeeDetailService;
import com.orangelife.service.propFeeAccount.IPropFeeAccountService;
import com.orangelife.service.propFeeApartment.IPropFeeApartmentService;
import com.orangelife.service.propFeeDetailImportLog.IPropFeeDetailImportLogService;
import com.orangelife.service.propFeeDetailImportLog.model.PropFeeDetailImportLogDto;
import com.orangelife.utils.IdUtil;
import com.orangelife.utils.ListSetUtils;
import com.orangelife.utils.PropertyUtils;
import com.orangelife.utils.StringUtils;

@Service("importFeeDetailHistory")
public class ImportFeeDetailHistoryImpl implements IImportFeeDetailHistory {
	@Resource(name = "propFeeAccountService")
	private IPropFeeAccountService propFeeAccountService;
	@Resource(name = "propFeeTypeService")
	private IPropFeeTypeService propFeeTypeService;
	@Resource(name = "feeDetailService")
	private IFeeDetailService feeDetailService;

	@Resource(name = "propFeeApartmentService")
	private IPropFeeApartmentService propFeeApartmentService;
	@Resource(name = "propFeeDetailImportLogService")
	private IPropFeeDetailImportLogService propFeeDetailImportLogService;

	private QiniuUtils qiniuUtils = new QiniuUtils();
	// private PropFeeDetailImportLogDto cmmImportLog = new
	// PropFeeDetailImportLogDto();

	/**
	 * 小区生成账单状态
	 * 
	 * */
	public static Map<String, String> commFeeStatus = new HashMap<String, String>();

	/**
	 * 小获取小区生成状态 1为锁定状态,， 返回boolean
	 * */
	public static boolean getFeeStatus(String commID) {
		synchronized (commFeeStatus) {
			if (commFeeStatus.get(commID) == null) {
				return false;
			} else if ("1".equals(commFeeStatus.get(commID))) {
				return true;
			}
			return false;
		}
	}

	/**
	 * 设置当状态为非锁定状态时设置为锁定状态, 返回boolean
	 * */
	public static boolean setFeeStatusLock(String commID) {
		synchronized (commFeeStatus) {
			if ("1".equals(commFeeStatus.get(commID))) {
				return false;
			} else {

				commFeeStatus.put(commID, "1");
				return true;
			}

		}
	}

	/**
	 * 设置当状态为锁定状态时设置为非锁定状态, 返回boolean
	 * */
	public static boolean setFeeStatusUnlock(String commID) {
		synchronized (commFeeStatus) {
			if ("1".equals(commFeeStatus.get(commID))) {
				commFeeStatus.put(commID, "0");

				return true;

			}
			return true;

		}
	}

	@Override
	public int importFeeDetailHistory(String commID, Sheet sheet,
			String fileName, String importType) throws AppBizException {
		PropFeeDetailImportLogDto cmmImportLog = new PropFeeDetailImportLogDto();

		int rowCount = sheet.getPhysicalNumberOfRows();// 获得总行数
		if (rowCount < 1) {
			throw new AppBizException(2, "sheet页无数据");
		}
		/****
		 * 添加失败日志
		 */

		cmmImportLog.setCreateuserID("1");
		cmmImportLog.setImportLogID(IdUtil.getuuId());
		cmmImportLog.setItemStat("1");
		cmmImportLog.setStatus("1");
		cmmImportLog.setTscreate(new Date());
		cmmImportLog.setTsedit(new Date());
		cmmImportLog.setFileName(fileName);
		propFeeDetailImportLogService.addPropFeeDetailImportLog(cmmImportLog);
		ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs = new ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService>(
				cmmImportLog, propFeeDetailImportLogService);

		Row row = sheet.getRow(0);// 第一行
		int columnCount = row.getLastCellNum();// 获取列数
		Map<String, Integer> columnMap = new HashMap<String, Integer>();

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("commID", commID);
		map.put("isShow", "1");

		List<Map<String, Object>> houseInfos = propFeeApartmentService
				.getHouseInfo(map);
		//
		List<Map<String, Object>> propFees = PropertyUtils
				.turnToEntity(propFeeTypeService.bauthfindPropFeeTypeByMap(map));
		if (propFees == null || propFees.size() <= 0) {
			logs.errMap.put(1, "亲，亲，该小区未配置类目");
			cmmImportLog.setStatus("3");
			cmmImportLog.setImportInfo("成功0条");
			String logurl = qiniuUtils.createErrorLogFile(logs.errMap);
			cmmImportLog.setLink(logurl);
			cmmImportLog.setFinishTime(new Date());
			cmmImportLog.setTsedit(new Date());
			cmmImportLog.setRemark("亲，该小区未配置类目");
			cmmImportLog.setCommID(commID);
			propFeeDetailImportLogService
					.editPropFeeDetailImportLog(cmmImportLog);
			throw new AppBizException(100002, "该小区未配置类目");
		}

		// 校验
		this.checkColum(row, propFees, commID, logs);

		for (int i = 0; i < columnCount; i++) {
			String columnName = row.getCell((short) i).getStringCellValue()
					.trim();

			// 空列后面就不再解析了
			if (StringUtils.isBlank(columnName)) {
				break;
			}
			if (columnName.equals("楼栋")) {
				columnMap.put("楼栋", i);
			}

			if (columnName.equals("房号")) {
				columnMap.put("房号", i);
			}
			if (columnName.equals("单元")) {
				columnMap.put("单元", i);
			}
			if (columnName.equals("是否预缴")) {
				columnMap.put("是否预缴", i);
			}
			if (columnName.equals("缴费日期")) {
				columnMap.put("缴费日期", i);
			}
			for (Map<String, Object> propFeeTypes : propFees) {
				if (columnName.equals("MX_"
						+ propFeeTypes.get("feeTypeName").toString())) {
					columnMap.put("MX_"
							+ propFeeTypes.get("feeTypeName").toString(), i);
				}
			}
		}
		// 校验字段是否缺失
		checkRecordColum(columnMap, commID, logs);
		// 获取要执行的数据
		Set<Map<String, Object>> recordDtos = notNull(commID, sheet, rowCount,
				columnMap, propFees, houseInfos, logs, importType);
		ListSetUtils listSetUtils = new ListSetUtils();
		List<List<Map<String, Object>>> li = listSetUtils.splitList(
				listSetUtils.setToList(recordDtos), 100);

		for (int j = 0; j < li.size(); j++) {

			logs.tasks.put(j + "", false);

		}
		for (int i = 0; i < li.size(); i++) {
			HandleFeeDetailHistoryThread thread = new HandleFeeDetailHistoryThread(
					commID, i + "", li.get(i), propFeeAccountService,
					feeDetailService, propFeeApartmentService, importType,
					houseInfos, logs);
			thread.start();
		}
		return columnCount;

	}

	@Override
	public int importFeeHistory(String commID, Sheet sheet, String fileName,
			String importType) throws AppBizException {
		Map<Integer, String> logmap = new TreeMap<Integer, String>();

		PropFeeDetailImportLogDto cmmImportLog = new PropFeeDetailImportLogDto();
		int rowCount = sheet.getPhysicalNumberOfRows();// 获得总行数
		if (rowCount < 1) {
			throw new AppBizException(2, "sheet页无数据");
		}

		/****
		 * 添加失败日志
		 */

		cmmImportLog.setCreateuserID("1");
		cmmImportLog.setImportLogID(IdUtil.getuuId());
		cmmImportLog.setItemStat("1");
		cmmImportLog.setStatus("1");
		cmmImportLog.setTscreate(new Date());
		cmmImportLog.setTsedit(new Date());
		cmmImportLog.setFileName(fileName);
		propFeeDetailImportLogService.addPropFeeDetailImportLog(cmmImportLog);
		ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs = new ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService>(
				cmmImportLog, propFeeDetailImportLogService);

		Row row = sheet.getRow(0);// 第一行
		int columnCount = row.getLastCellNum();// 获取列数
		Map<String, Integer> columnMap = new HashMap<String, Integer>();

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("commID", commID);
		map.put("isShow", "1");
		List<Map<String, Object>> houseInfos = propFeeApartmentService
				.getHouseInfo(map);
		List<Map<String, Object>> propFees = PropertyUtils
				.turnToEntity(propFeeTypeService.bauthfindPropFeeTypeByMap(map));

		if (propFees == null || propFees.size() <= 0) {
			logmap.put(1, "亲,该小区未配置类目");
			cmmImportLog.setStatus("3");
			cmmImportLog.setImportInfo("成功0条");
			String logurl = qiniuUtils.createErrorLogFile(logmap);
			cmmImportLog.setLink(logurl);
			cmmImportLog.setFinishTime(new Date());
			cmmImportLog.setTsedit(new Date());
			cmmImportLog.setRemark("亲，该小区未配置类目");
			cmmImportLog.setCommID(commID);
			propFeeDetailImportLogService
					.editPropFeeDetailImportLog(cmmImportLog);
			throw new AppBizException(100002, "该小区未配置类目");
		}

		this.checkColums(row, propFees, commID, logs);

		for (int i = 0; i < columnCount; i++) {
			String columnName = row.getCell((short) i).getStringCellValue()
					.trim();
			// 空列后面就不再解析了
			if (StringUtils.isBlank(columnName)) {
				break;
			}

			if (columnName.equals("房屋管理号")) {
				columnMap.put("房屋管理号", i);
			}
			if (columnName.equals("楼栋")) {
				columnMap.put("楼栋", i);
			}

			if (columnName.equals("房号")) {
				columnMap.put("房号", i);
			}
			if (columnName.equals("单元")) {
				columnMap.put("单元", i);
			}
			if (columnName.equals("是否预缴")) {
				columnMap.put("是否预缴", i);
			}
			if (columnName.equals("缴费日期")) {
				columnMap.put("缴费日期", i);
			}
			for (Map<String, Object> propFeeTypes : propFees) {
				if (columnName.equals("MX_"
						+ propFeeTypes.get("feeTypeName").toString())) {
					columnMap.put("MX_"
							+ propFeeTypes.get("feeTypeName").toString(), i);
				}
			}
		}

		checkRecordColums(columnMap, commID, logs);
		Set<Map<String, Object>> recordDtos = notNull(commID, sheet, rowCount,
				columnMap, propFees, houseInfos, logs, importType);
		ListSetUtils listSetUtils = new ListSetUtils();
		List<List<Map<String, Object>>> li = listSetUtils.splitList(
				listSetUtils.setToList(recordDtos), 100);
		for (int i = 0; i < li.size(); i++) {
			HandleFeeDetailHistoryThread thread = new HandleFeeDetailHistoryThread(
					commID, "线程[" + (i) + "] ", li.get(i),
					propFeeAccountService, feeDetailService,
					propFeeApartmentService, importType, houseInfos, logs);
			thread.start();
		}
		return columnCount;

	}

	public boolean checkRecordColum(
			Map<String, Integer> map,
			String commID,
			ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs)
			throws AppBizException {

		try {

			if (map == null || map.size() <= 0) {
				throw new AppBizException(99, "亲,使用正确的excel的格式");
			}

			if (!map.containsKey("楼栋")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(缺乏楼栋)");
			}
			if (!map.containsKey("房号")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(缺乏房号)");
			}
			if (!map.containsKey("单元")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式 (缺乏单元)");
			}
			if (!map.containsKey("是否预缴")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式 (缺乏是否预缴)");
			}
			if (!map.containsKey("缴费日期")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式 (缺乏缴费日期)");
			}
		} catch (AppBizException e) {
			logs.errMap.put(1, e.getMessage());

			/****
			 * 添加失败日志
			 */
			logs.getImportLog().setStatus("3");
			logs.getImportLog().setImportInfo("成功0条");
			String logurl = logs.getErrUrl();
			logs.getImportLog().setLink(logurl);
			logs.getImportLog().setFinishTime(new Date());
			logs.getImportLog().setTsedit(new Date());
			logs.getImportLog().setCommID(commID);
			logs.getImportService().editPropFeeDetailImportLog(
					logs.getImportLog());
			throw new AppBizException(99, e.getMessage());

		}

		return true;

	}

	public void checkRecordColums(
			Map<String, Integer> map,
			String commID,
			ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs)
			throws AppBizException {

		try {
			if (map == null || map.size() <= 0) {
				throw new AppBizException(99, "亲,使用正确的excel的格式");
			}
			if (!map.containsKey("房屋管理号")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(房屋管理号)");
			}

			if (!map.containsKey("楼栋")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(缺乏楼栋)");
			}
			if (!map.containsKey("房号")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(缺乏房号)");
			}
			if (!map.containsKey("单元")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(缺乏单元)");
			}
			if (!map.containsKey("是否预缴")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(缺乏是否预缴)");
			}
			if (!map.containsKey("缴费日期")) {
				throw new AppBizException(99, "亲,使用正确的excel的格式(缺乏缴费日期)");
			}
		} catch (AppBizException e) {
			logs.errMap.put(1, e.getMessage());
			/****
			 * 添加失败日志
			 */
			logs.getImportLog().setStatus("3");
			logs.getImportLog().setImportInfo("成功0条");
			String logurl = logs.getErrUrl();
			logs.getImportLog().setLink(logurl);
			logs.getImportLog().setFinishTime(new Date());
			logs.getImportLog().setTsedit(new Date());
			logs.getImportLog().setCommID(commID);
			logs.getImportService().editPropFeeDetailImportLog(
					logs.getImportLog());
			throw new AppBizException(99, e.getMessage());
		}

	}

	public void checkColum(
			Row row,
			List<Map<String, Object>> propFees,
			String commID,
			ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs)
			throws AppBizException {
		List<String> feeType = new ArrayList<String>();
		for (Map<String, Object> map : propFees) {
			feeType.add("MX_" + map.get("feeTypeName").toString());
		}
		feeType.add("房屋管理号");
		feeType.add("楼栋");
		feeType.add("房号");
		feeType.add("单元");
		feeType.add("缴费日期");
		feeType.add("是否预缴");
		StringBuffer buffer = new StringBuffer();
		int columnCount = row.getLastCellNum();// 获取列数
		for (int i = 0; i < columnCount; i++) {
			String columnName = row.getCell((short) i).getStringCellValue()
					.trim();
			// 遇到空列就不再解析下面的列了
			if (StringUtils.isBlank(columnName)) {
				break;
			}
			if (!feeType.contains(columnName)) {
				// throw new AppBizException(99, "亲,该excel不是当前小区的");
				buffer.append(columnName).append(",");
			}
		}

		if (!StringUtils.isBlank(buffer.toString())) {
			logs.errMap.put(1, "亲，请使用正确的excel格式(  " + buffer.toString()
					+ "不是该小区的列数)");
			/****
			 * 添加失败日志
			 */
			logs.getImportLog().setStatus("3");
			logs.getImportLog().setImportInfo("成功0条");
			String logurl = logs.getErrUrl();
			logs.getImportLog().setLink(logurl);
			logs.getImportLog().setFinishTime(new Date());
			logs.getImportLog().setTsedit(new Date());
			logs.getImportLog().setCommID(commID);
			logs.getImportService().editPropFeeDetailImportLog(
					logs.getImportLog());
			throw new AppBizException(99, "亲,该excel不是当前小区的");
		}
	}

	public void checkColums(
			Row row,
			List<Map<String, Object>> propFees,
			String commID,
			ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs)
			throws AppBizException {
		List<String> feeType = new ArrayList<String>();
		for (Map<String, Object> map : propFees) {
			feeType.add("MX_" + map.get("feeTypeName").toString());
		}
		StringBuffer buffer = new StringBuffer();
		feeType.add("房屋管理号");
		feeType.add("楼栋");
		feeType.add("楼栋");
		feeType.add("房号");
		feeType.add("单元");
		feeType.add("缴费日期");
		feeType.add("是否预缴");
		int columnCount = row.getLastCellNum();// 获取列数
		for (int i = 0; i < columnCount; i++) {

			String columnName = row.getCell((short) i).getStringCellValue()
					.trim();
			// 遇到空列就不再解析下面的列了
			if (StringUtils.isBlank(columnName)) {
				break;
			}

			if (!feeType.contains(columnName)) {
				// throw new AppBizException(99, "亲,该excel不是当前小区的");
				buffer.append(columnName).append(",");
			}
		}
		if (!StringUtils.isBlank(buffer.toString())) {
			logs.errMap.put(1, "亲，请使用正确的excel格式(  " + buffer.toString()
					+ "不是该小区的列数)");
			/****
			 * 添加失败日志
			 */
			logs.getImportLog().setStatus("3");
			logs.getImportLog().setImportInfo("成功0条");
			String logurl = logs.getErrUrl();
			logs.getImportLog().setLink(logurl);
			logs.getImportLog().setFinishTime(new Date());
			logs.getImportLog().setTsedit(new Date());
			logs.getImportLog().setCommID(commID);
			logs.getImportService().editPropFeeDetailImportLog(
					logs.getImportLog());
			throw new AppBizException(99, "亲,该excel不是当前小区的");
		}
	}

	public Set<Map<String, Object>> notNull(
			String commID,
			Sheet sheet,
			int rowCount,
			Map<String, Integer> columnMap,
			List<Map<String, Object>> feeTypes,
			List<Map<String, Object>> houseInfos,
			ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs,
			String importType) throws AppBizException {
		Set<Map<String, Object>> propFeeMeterRecordDtos = new HashSet<Map<String, Object>>();

		Map<String, HashMap<String, Object>> importData = new HashMap<String, HashMap<String, Object>>();

		Row firstRow = sheet.getRow(1);
		int errortol = 0;
		int total = 0;
		if (firstRow == null) {

			logs.errMap.put(1, "请最少填写一行信息");
			logs.getImportLog().setStatus("3");
			logs.getImportLog().setImportInfo("成功0条");
			String logurl = logs.getErrUrl();
			logs.getImportLog().setLink(logurl);
			logs.getImportLog().setFinishTime(new Date());
			logs.getImportLog().setTsedit(new Date());
			logs.getImportLog().setCommID(commID);
			logs.getImportService().editPropFeeDetailImportLog(
					logs.getImportLog());
			throw new AppBizException(99, "亲，请最少填写一行信息");
			// logs.setIsbreak(true);
			// throw new AppBizException(99, "亲，请最少填写一行信息");
		}

		int rownum = 0;
		String apartmentID = null;
		String feeDate = null;
		String ispre = null;
		String status = null;
		for (int i = 1; i < rowCount; i++) {
			try {

				Row dataRow = sheet.getRow(i);
				if (dataRow == null) {
					break;
				}
				rownum = i + 1;

				/***
				 * 跳过空白行
				 */
				if ("1".equals(importType)) {

					if (StringUtils.isBlank(this.getCellValue(dataRow
							.getCell(columnMap.get("楼栋"))))
							&& StringUtils.isBlank(this.getCellValue(dataRow
									.getCell(columnMap.get("房号"))))
							&& StringUtils.isBlank(this.getCellValue(dataRow
									.getCell(columnMap.get("单元"))))
							&& StringUtils.isBlank(this.getCellValue(dataRow
									.getCell(columnMap.get("是否预缴"))))
							&& StringUtils.isBlank(this.getCellValue(dataRow
									.getCell(columnMap.get("缴费日期"))))) {

						break;

					}

					if (StringUtils.isBlank(this.getCellValue(dataRow
							.getCell(columnMap.get("楼栋"))))) {
						logs.errMap.put(i + 1, "亲，第" + rownum + "行楼栋为空");
						logs.addErrnum();
						continue;
					}

					if (StringUtils.isBlank(this.getCellValue(dataRow
							.getCell(columnMap.get("房号"))))) {
						// throw new AppBizException(2, "亲，第" + i + "行房号为空");
						logs.errMap.put(rownum, "亲，第" + rownum + "行房号为空");
						logs.addErrnum();
						continue;
					}

				}

				/***
				 * 跳过空白行
				 */
				if ("2".equals(importType)) {

					if (StringUtils.isBlank(this.getCellValue(dataRow
							.getCell(columnMap.get("房屋管理号"))))
							&& StringUtils.isBlank(this.getCellValue(dataRow
									.getCell(columnMap.get("是否预缴"))))
							&& StringUtils.isBlank(this.getCellValue(dataRow
									.getCell(columnMap.get("缴费日期"))))) {

						break;

					}

					if (StringUtils.isBlank(this.getCellValue(dataRow
							.getCell(columnMap.get("房屋管理号"))))) {
						logs.errMap.put(rownum, "亲，第" + rownum + "房屋管理号为空");
						logs.addErrnum();
						continue;
					}

				}

				if (StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("是否预缴"))))) {
					// throw new AppBizException(2, "亲，第" + i + "行 是否预缴为空");

					logs.errMap.put(rownum, "亲，第" + rownum + "行是否预缴为空");
					logs.addErrnum();
					continue;
				}
				String isPay = this.getCellValue(dataRow.getCell(columnMap
						.get("是否预缴")));
				if (!isPay.equals("是") && !isPay.equals("否")) {
					logs.errMap.put(rownum, "亲，第" + rownum + "行 是否预缴信息错误");
					logs.addErrnum();
					continue;
					// throw new AppBizException(2, "亲，第" + i + "行 是否预缴信息错误");
				}
				if (StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("缴费日期"))))) {
					// throw new AppBizException(2, "亲，第" + i + "行 缴费日期为空");
					logs.errMap.put(rownum, "亲，第" + rownum + "行缴费日期为空");
					logs.addErrnum();
					continue;
				}
				if (!this.getTimeDate(this.getCellValue(dataRow
						.getCell(columnMap.get("缴费日期"))))) {
					// throw new AppBizException(2, "亲，第" +
					// +"行缴费日期错误(正确格式yyyy-mm)");
					logs.errMap.put(rownum, "亲，第" + rownum
							+ "行缴费日期错误(正确格式yyyy-mm)");
					logs.addErrnum();
					continue;
				}

				if (!this.getLimtDate(this.getCellValue(dataRow
						.getCell(columnMap.get("缴费日期"))))) {
					// throw new AppBizException(2, "亲，第" +
					// +"行缴费日期错误(正确格式yyyy-mm)");
					logs.errMap.put(rownum, "亲，第" + rownum
							+ "行缴费日期错误(请输入正确的月份)");
					logs.addErrnum();
					continue;
				}

				boolean isCheck = false;

				if ("1".equals(importType)) {

					String unitName = this.getCellValue(dataRow
							.getCell(columnMap.get("单元")));
					String buildingName = this.getCellValue(dataRow
							.getCell(columnMap.get("楼栋")));
					String apartmentName = this.getCellValue(dataRow
							.getCell(columnMap.get("房号")));
					for (Map<String, Object> house : houseInfos) {

						if (StringUtils.isBlank(unitName)) {
							if (house.get("buildingName").toString()
									.equals(buildingName)
									&& house.get("apartmentNum").toString()
											.equals(apartmentName)
									&& StringUtils.isBlank(StringUtils
											.toString(house.get("unitName")))) {
								isCheck = true;

								apartmentID = house.get("apartmentID")
										.toString();
								break;
							}
						} else {
							if (house.get("buildingName").toString()
									.equals(buildingName)
									&& house.get("apartmentNum").toString()
											.equals(apartmentName)
									&& unitName.equals(house.get("unitName")
											.toString())) {
								isCheck = true;
								apartmentID = house.get("apartmentID")
										.toString();
								break;
							}
						}

					}
					if (!isCheck) {
						logs.errMap
								.put(rownum,
										"亲，第"
												+ rownum
												+ "行 楼栋"
												+ buildingName
												+ "-"
												+ (StringUtils
														.isBlank(unitName) ? ""
														: "单元" + unitName + "-")
												+ "房号为" + apartmentName
												+ "房屋信息在该小区不存在");
						logs.addErrnum();
						continue;
					}
				}

				if ("2".equals(importType)) {

					isCheck = false;
					String sourceID = this.getCellValue(dataRow
							.getCell(columnMap.get("房屋管理号")));
					for (Map<String, Object> house : houseInfos) {
						if (house.get("sourceID") != null) {
							if (house.get("sourceID").toString()
									.equals(sourceID)) {
								isCheck = true;
								apartmentID = house.get("apartmentID")
										.toString();
								break;
							}
						}

					}
					if (!isCheck) {
						logs.errMap.put(rownum, "亲，第" + rownum + "行" + "房屋管理号为"
								+ sourceID + "的房屋信息在该小区不存在");

						logs.addErrnum();
						continue;
					}
				}

				StringBuffer buffer = new StringBuffer();
				boolean flag = true;

				if (isPay.equals("是")) {
					ispre = "2";
					status = "1";

				} else {
					ispre = "1";
					status = "0";
				}
				feeDate = this.getCellValue(dataRow.getCell(columnMap
						.get("缴费日期")));

				for (Map<String, Object> propFeeType : feeTypes) {
					String feeTypeName = "MX_"
							+ propFeeType.get("feeTypeName").toString();
					if (columnMap.get(feeTypeName) != null) {

						String money = this.getCellValue(
								dataRow.getCell(columnMap.get(feeTypeName)),
								"0.##");

						if (!StringUtils.isBlank(money)) {

							flag = false;
							if (!StringUtils.isDouble(money)) {
								// throw new AppBizException(2, "亲，第" + rownum +
								// "行"
								// + feeTypeName + "金额格式错误");
								buffer.append(feeTypeName + "金额格式错误,");
								logs.addErrnum();
								continue;

							}
							if (new BigDecimal(money).compareTo(new BigDecimal(
									"0")) <= 0) {
								// throw new AppBizException(2, "亲，第" + rownum +
								// "行"
								// + feeTypeName + "金额格式错误");
								buffer.append(feeTypeName + "金额必须大于0.00,");
								logs.addErrnum();
								continue;

							}

							HashMap<String, Object> details1 = importData
									.get(apartmentID
											+ propFeeType.get("feeTypeID")
													.toString() + feeDate);
							if (details1 != null) {
								// details1.put("isok", false);
								buffer.append(feeTypeName + "与 第"
										+ details1.get("rownum") + "行的项目重复,");
								logs.addErrnum();

								continue;
							}

							HashMap<String, Object> details = new HashMap<String, Object>();
							details.put("rownum", rownum);
							details.put("feeTypeID",
									propFeeType.get("feeTypeID").toString());
							details.put("feeTypeName", feeTypeName);

							details.put("apartmentID", apartmentID);
							details.put("feeDate", feeDate);
							details.put("isok", true);
							details.put("money", money);
							details.put("status", status);
							details.put("ispre", ispre);
							importData.put(
									apartmentID
											+ propFeeType.get("feeTypeID")
													.toString() + feeDate,
									details);

							propFeeMeterRecordDtos.add(details);

						}

					}
				}

				if (!StringUtils.isBlank(buffer.toString())) {
					// throw new AppBizException(2, "亲，请输入最少一条缴费类目");
					logs.errMap.put(rownum,
							"亲，第" + rownum + "行" + buffer.toString());

					continue;
				}
				if (flag) {
					// throw new AppBizException(2, "亲，请输入最少一条缴费类目");
					logs.errMap.put(rownum, "亲，第" + rownum + "行请填写一条费用类目的缴费信息");
					logs.addErrnum();
					continue;
				}

				//
				//
				//
				//
				//
				// if (2 == (getCellInfoByHouseInfo(i + 1, dataRow, columnMap,
				// logs.errMap, feeTypes, houseInfos,Type))) {
				// errortol++;
				// continue;
				// } else if (1 == (getCellInfoByHouseInfo(i + 1, dataRow,
				// columnMap, logs.errMap, feeTypes, houseInfos))) {
				// logs.errMap.put(i + 1, "该行出现了的空行，导入停止");
				// break;
				//
				// } else if (3 == (getCellInfoByHouseInfo(i + 1, dataRow,
				// columnMap, logs.errMap, feeTypes, houseInfos))) {
				// // logmap.put(j + 1, "该行出现了的空行，导入停止");
				// break;
				//
				// }
				// account.put("rowNum",i + 1);
				// account.put("commID", commID);
				// account.put("buildingName",
				// this.getCellValue(dataRow.getCell(columnMap.get("楼栋"))));
				// account.put("apartmentName",
				// this.getCellValue(dataRow.getCell(columnMap.get("房号"))));
				// String unitName = this.getCellValue(dataRow.getCell(columnMap
				// .get("单元")));
				// if (!StringUtils.isBlank(unitName)) {
				// account.put("unitName", unitName);
				// } else {
				// account.put("unitName", null);
				// }
				//
				// String isPay = this.getCellValue(dataRow.getCell(columnMap
				// .get("是否预缴")));
				//
				// if (isPay.equals("是")) {
				// account.put("isPay", "2");
				// account.put("status", "1");
				// } else {
				// account.put("isPay", "1");
				// account.put("status", "0");
				// }
				// account.put("curTime", this.getCellValue(dataRow
				// .getCell(columnMap.get("缴费日期"))));
				//
				//
				//
				// List<Map<String, Object>> feeDetails = new
				// ArrayList<Map<String, Object>>();
				// for (Map<String, Object> propFeeType : feeTypes) {
				// String feeTypeName = "MX_"
				// + propFeeType.get("feeTypeName").toString();
				// if (columnMap.get(feeTypeName) != null) {
				// String money = this.getCellValue(
				// dataRow.getCell(columnMap.get(feeTypeName)),
				// "0.##");
				// if (!StringUtils.isBlank(money)) {
				// if (!StringUtils.isDouble(money)) {
				// // throw new AppBizException(2, "亲，第" + i + "行"
				// // + feeTypeName + "金额格式错误");
				// logs.errMap.put(i + 1,
				// propFeeType.get("feeTypeName").toString()+"金额格式错误");
				// continue;
				// }
				// Map<String, Object> details = new HashMap<String, Object>();
				// details.put("feeTypeID",
				// propFeeType.get("feeTypeID").toString());
				// details.put("money", money);
				// details.put("feeTypeName",
				// propFeeType.get("feeTypeName").toString());
				// feeDetails.add(details);
				// }
				//
				// }
				// }
				// if (feeDetails == null || feeDetails.size() <= 0) {
				//
				//
				//
				// throw new AppBizException(2, "亲，请输入最少一条缴费类目");
				// }
				// account.put("details", feeDetails);
				// propFeeMeterRecordDtos.add(account);
				// total++;
				//
			} catch (Exception e) {
				e.printStackTrace();
				logs.errMap.put(i + 1, "行数据转换错误,错误原因：" + e.getMessage());
				errortol++;
			}

		}

		return propFeeMeterRecordDtos;
	}

	public Set<Map<String, Object>> notNulls(
			String commID,
			Sheet sheet,
			int rowCount,
			Map<String, Integer> columnMap,
			List<Map<String, Object>> feeTypes,
			List<Map<String, Object>> houseInfos,
			ImportLogs<PropFeeDetailImportLogDto, IPropFeeDetailImportLogService> logs)
			throws AppBizException {
		int errortol = 0;
		int total = 0;
		Set<Map<String, Object>> propFeeMeterRecordDtos = new HashSet<Map<String, Object>>();
		Map<String, HashMap<String, Object>> importData = new HashMap<String, HashMap<String, Object>>();
		Row firstRow = sheet.getRow(1);
		if (firstRow == null) {

			logs.errMap.put(1, "请最少填写一行信息");
			logs.getImportLog().setStatus("3");
			logs.getImportLog().setImportInfo("成功0条");
			String logurl = logs.getErrUrl();
			logs.getImportLog().setLink(logurl);
			logs.getImportLog().setFinishTime(new Date());
			logs.getImportLog().setTsedit(new Date());
			logs.getImportLog().setCommID(commID);
			logs.getImportService().editPropFeeDetailImportLog(
					logs.getImportLog());
			throw new AppBizException(99, "亲，请最少填写一行信息");

		}
		for (int i = 1; i < rowCount; i++) {
			try {

				Map<String, Object> account = new HashMap<String, Object>();
				Row dataRow = sheet.getRow(i);
				if (dataRow == null) {
					break;
				}
				if (2 == (getCellInfoBySourceID(i + 1, dataRow, columnMap,
						logs.errMap, feeTypes, houseInfos))) {
					errortol++;
					continue;
				} else if (1 == (getCellInfoBySourceID(i + 1, dataRow,
						columnMap, logs.errMap, feeTypes, houseInfos))) {
					logs.errMap.put(i + 1, "该行出现了的空行，导入停止");
					break;

				} else if (3 == (getCellInfoBySourceID(i + 1, dataRow,
						columnMap, logs.errMap, feeTypes, houseInfos))) {
					// logmap.put(j + 1, "该行出现了的空行，导入停止");
					break;

				}

				account.put("rowNum", i + 1);
				account.put("sourceID", this.getCellValue(dataRow
						.getCell(columnMap.get("房屋管理号"))));
				account.put("commID", commID);
				if (StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("是否预缴"))))) {
					throw new AppBizException(2, "亲，第" + i + "行 是否预缴为空");
				}
				String isPay = this.getCellValue(dataRow.getCell(columnMap
						.get("是否预缴")));
				if (isPay.equals("是")) {
					account.put("isPay", "2");
					account.put("status", "1");
				} else {
					account.put("isPay", "1");
					account.put("status", "0");
				}
				if (!this.getTimeDate(this.getCellValue(dataRow
						.getCell(columnMap.get("缴费日期"))))) {
					throw new AppBizException(2, "亲，第" + i
							+ "行缴费日期错误(正确格式yyyy-mm)");
				}
				account.put("curTime", this.getCellValue(dataRow
						.getCell(columnMap.get("缴费日期"))));
				List<Map<String, Object>> feeDetails = new ArrayList<Map<String, Object>>();
				for (Map<String, Object> propFeeType : feeTypes) {
					String feeTypeName = "MX_"
							+ propFeeType.get("feeTypeName").toString();

					if (columnMap.get(feeTypeName) != null) {
						String money = this.getCellValue(
								dataRow.getCell(columnMap.get(feeTypeName)),
								"0.##");
						if (!StringUtils.isBlank(money)) {
							if (!StringUtils.isDouble(money)) {
								// throw new AppBizException(2, "亲，第" + i + "行"
								// + feeTypeName + "金额格式错误");
								continue;
							}
							Map<String, Object> details = new HashMap<String, Object>();
							details.put("feeTypeID",
									propFeeType.get("feeTypeID").toString());
							details.put("money", money);
							feeDetails.add(details);
						}

					}
				}
				if (feeDetails == null || feeDetails.size() <= 0) {
					throw new AppBizException(2, "亲，请输入最少一条缴费类目");
				}
				account.put("details", feeDetails);
				propFeeMeterRecordDtos.add(account);
				total++;
			} catch (Exception e) {
				// e.printStackTrace();
				logs.errMap.put(i + 1, "行数据转换错误,错误原因：" + e.getMessage());
				errortol++;
			}
		}

		return propFeeMeterRecordDtos;
	}

	public int getCellInfoByHouseInfo(int rownum, Row dataRow,
			Map<String, Integer> columnMap, Map<Integer, String> logmap,
			List<Map<String, Object>> feeTypes,
			List<Map<String, Object>> houseInfos) throws AppBizException {

		/***
		 * 跳过空白行
		 */
		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("楼栋"))))
				&& StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("房号"))))
				&& StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("单元"))))
				&& StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("是否预缴"))))
				&& StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("缴费日期"))))) {
			return 1;

		}
		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("楼栋"))))) {
			logmap.put(rownum, "亲，第" + rownum + "行楼栋为空");
			return 2;
			// throw new AppBizException(2, "亲，第" + i + "行楼栋为空");
		}

		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("房号"))))) {
			// throw new AppBizException(2, "亲，第" + i + "行房号为空");
			logmap.put(rownum, "亲，第" + rownum + "行房号为空");
			return 2;
		}
		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("是否预缴"))))) {
			// throw new AppBizException(2, "亲，第" + i + "行 是否预缴为空");

			logmap.put(rownum, "亲，第" + rownum + "行是否预缴为空");
			return 2;
		}
		String isPay = this
				.getCellValue(dataRow.getCell(columnMap.get("是否预缴")));
		if (!isPay.equals("是") && !isPay.equals("否")) {
			logmap.put(rownum, "亲，第" + rownum + "行 是否预缴信息错误");
			return 2;
			// throw new AppBizException(2, "亲，第" + i + "行 是否预缴信息错误");
		}
		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("缴费日期"))))) {
			// throw new AppBizException(2, "亲，第" + i + "行 缴费日期为空");
			logmap.put(rownum, "亲，第" + rownum + "行缴费日期为空");
			return 2;
		}
		if (!this.getTimeDate(this.getCellValue(dataRow.getCell(columnMap
				.get("缴费日期"))))) {
			// throw new AppBizException(2, "亲，第" + +"行缴费日期错误(正确格式yyyy-mm)");
			logmap.put(rownum, "亲，第" + rownum + "行缴费日期错误(正确格式yyyy-mm)");
			return 2;
		}

		if (!this.getLimtDate(this.getCellValue(dataRow.getCell(columnMap
				.get("缴费日期"))))) {
			// throw new AppBizException(2, "亲，第" + +"行缴费日期错误(正确格式yyyy-mm)");
			logmap.put(rownum, "亲，第" + rownum + "行缴费日期错误(请输入正确的月份)");
			return 2;
		}

		boolean isCheck = false;
		String unitName = this
				.getCellValue(dataRow.getCell(columnMap.get("单元")));
		String buildingName = this.getCellValue(dataRow.getCell(columnMap
				.get("楼栋")));
		String apartmentName = this.getCellValue(dataRow.getCell(columnMap
				.get("房号")));
		for (Map<String, Object> house : houseInfos) {

			if (StringUtils.isBlank(unitName)) {
				if (house.get("buildingName").toString().equals(buildingName)
						&& house.get("apartmentNum").toString()
								.equals(apartmentName)
						&& StringUtils.isBlank(StringUtils.toString(house
								.get("unitName")))) {
					isCheck = true;
				}
			} else {
				if (house.get("buildingName").toString().equals(buildingName)
						&& house.get("apartmentNum").toString()
								.equals(apartmentName)
						&& unitName.equals(house.get("unitName").toString())) {
					isCheck = true;
				}
			}

		}
		if (!isCheck) {
			logmap.put(rownum, "亲，第"
					+ rownum
					+ "行 楼栋"
					+ buildingName
					+ "-"
					+ (StringUtils.isBlank(unitName) ? "" : "单元" + unitName
							+ "-") + "房号为" + apartmentName + "房屋信息在该小区不存在");
			return 2;
		}

		StringBuffer buffer = new StringBuffer();
		List<Map<String, Object>> feeDetails = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> propFeeType : feeTypes) {
			String feeTypeName = "MX_"
					+ propFeeType.get("feeTypeName").toString();
			if (columnMap.get(feeTypeName) != null) {
				String money = this.getCellValue(
						dataRow.getCell(columnMap.get(feeTypeName)), "0.##");
				if (!StringUtils.isBlank(money)) {
					if (!StringUtils.isDouble(money)) {
						// throw new AppBizException(2, "亲，第" + rownum + "行"
						// + feeTypeName + "金额格式错误");
						buffer.append(feeTypeName + "金额格式错误,");
						continue;
					}
					Map<String, Object> details = new HashMap<String, Object>();
					details.put("feeTypeID", propFeeType.get("feeTypeID")
							.toString());
					details.put("money", money);
					feeDetails.add(details);
				}

			}
		}

		if (!StringUtils.isBlank(buffer.toString())) {
			// throw new AppBizException(2, "亲，请输入最少一条缴费类目");
			logmap.put(rownum, "亲，第" + rownum + "行" + buffer.toString());
			return 2;
		}
		if (feeDetails == null || feeDetails.size() <= 0) {
			// throw new AppBizException(2, "亲，请输入最少一条缴费类目");
			logmap.put(rownum, "亲，第" + rownum + "行请填写一条费用类目的缴费信息");
			return 2;
		}

		return 0;
	}

	public int getCellInfoBySourceID(int rownum, Row dataRow,
			Map<String, Integer> columnMap, Map<Integer, String> logmap,
			List<Map<String, Object>> feeTypes,
			List<Map<String, Object>> houseInfos) throws AppBizException {

		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("房屋管理号"))))
				&& StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("是否预缴"))))
				&& StringUtils.isBlank(this.getCellValue(dataRow
						.getCell(columnMap.get("缴费日期"))))) {
			return 1;

		}

		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("房屋管理号"))))) {
			// throw new AppBizException(2, "亲，第" + i + "行房屋管理号为空");
			logmap.put(rownum, "亲，第" + rownum + "行房屋管理号为空");
		}
		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("是否预缴"))))) {
			// throw new AppBizException(2, "亲，第" + i + "行 是否预缴为空");
			logmap.put(rownum, "亲，第" + rownum + "行是否预缴为空");
			return 2;
		}
		String isPay = this
				.getCellValue(dataRow.getCell(columnMap.get("是否预缴")));
		if (!isPay.equals("是") && !isPay.equals("否")) {
			logmap.put(rownum, "亲，第" + rownum + "行 是否预缴信息错误");
			return 2;
			// throw new AppBizException(2, "亲，第" + i + "行 是否预缴信息错误");
		}
		if (StringUtils.isBlank(this.getCellValue(dataRow.getCell(columnMap
				.get("缴费日期"))))) {
			// throw new AppBizException(2, "亲，第" + i + "行 缴费日期为空");
			logmap.put(rownum, "亲，第" + rownum + "行缴费日期为空");
			return 2;
		}
		if (!this.getTimeDate(this.getCellValue(dataRow.getCell(columnMap
				.get("缴费日期"))))) {
			// throw new AppBizException(2, "亲，第" + +"行缴费日期错误(正确格式yyyy-mm)");
			logmap.put(rownum, "亲，第" + rownum + "行缴费日期错误(正确格式yyyy-mm)");
			return 2;
		}
		if (!this.getLimtDate(this.getCellValue(dataRow.getCell(columnMap
				.get("缴费日期"))))) {
			// throw new AppBizException(2, "亲，第" + +"行缴费日期错误(正确格式yyyy-mm)");
			logmap.put(rownum, "亲，第" + rownum + "行缴费日期错误(请输入正确的月份)");
			return 2;
		}
		boolean isCheck = false;
		String sourceID = this.getCellValue(dataRow.getCell(columnMap
				.get("房屋管理号")));
		for (Map<String, Object> house : houseInfos) {
			if (house.get("sourceID") != null) {
				if (house.get("sourceID").toString().equals(sourceID)) {
					isCheck = true;
				}
			}

		}
		if (!isCheck) {
			logmap.put(rownum, "亲，第" + rownum + "行" + "房屋管理号为" + sourceID
					+ "的房屋信息在该小区不存在");
			return 2;
		}

		StringBuffer buffer = new StringBuffer();
		List<Map<String, Object>> feeDetails = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> propFeeType : feeTypes) {
			String feeTypeName = "MX_"
					+ propFeeType.get("feeTypeName").toString();
			if (columnMap.get(feeTypeName) != null) {
				String money = this.getCellValue(
						dataRow.getCell(columnMap.get(feeTypeName)), "0.##");
				if (!StringUtils.isBlank(money)) {
					if (!StringUtils.isDouble(money)) {
						// throw new AppBizException(2, "亲，第" + rownum + "行"
						// + feeTypeName + "金额格式错误");
						buffer.append(feeTypeName + "金额格式错误,");
						continue;
					}
					Map<String, Object> details = new HashMap<String, Object>();
					details.put("feeTypeID", propFeeType.get("feeTypeID")
							.toString());
					details.put("money", money);
					feeDetails.add(details);
				}

			}
		}
		if (!StringUtils.isBlank(buffer.toString())) {
			// throw new AppBizException(2, "亲，请输入最少一条缴费类目");
			logmap.put(rownum, "亲，第" + rownum + "行" + buffer.toString());
			return 2;
		}
		if (feeDetails == null || feeDetails.size() <= 0) {
			// throw new AppBizException(2, "亲，请输入最少一条缴费类目");
			logmap.put(rownum, "亲，第" + rownum + "行请填写一条费用类目的缴费信息");
			return 2;
		}

		return 0;
	}

	public String getCellValue(Cell cell) throws AppBizException {
		String cellValue = null;
		try {
			if (cell != null) {
				switch (cell.getCellType()) {
				case Cell.CELL_TYPE_NUMERIC: {
					if (DateUtil.isCellDateFormatted(cell)) {
						Date date = cell.getDateCellValue();
						SimpleDateFormat format = new SimpleDateFormat(
								"yyyy-MM-dd HH:mm:ss");
						cellValue = format.format(date);

					} else {
						DecimalFormat df = new DecimalFormat("#");
						cellValue = df.format(cell.getNumericCellValue());

					}
				}
					break;
				case Cell.CELL_TYPE_STRING: {
					cellValue = cell.getStringCellValue().trim();
				}
					break;

				default:
					break;
				}
			}
		} catch (Exception e) {
			throw new AppBizException(99, e.getMessage());
		}
		return cellValue;
	}

	private String getCellValue(Cell cell, String format1)
			throws AppBizException {
		String cellValue = null;
		try {
			if (cell != null) {
				switch (cell.getCellType()) {
				case Cell.CELL_TYPE_NUMERIC: {
					if (DateUtil.isCellDateFormatted(cell)) {
						Date date = cell.getDateCellValue();
						SimpleDateFormat format = new SimpleDateFormat(
								"yyyy-MM-dd HH:mm:ss");
						cellValue = format.format(date);

					} else {
						DecimalFormat df = new DecimalFormat(
								format1 == null ? "#" : format1);
						cellValue = df.format(cell.getNumericCellValue());
						// cellValue = String.valueOf((int) cell
						// .getNumericCellValue());
					}
				}
					break;
				case Cell.CELL_TYPE_STRING: {
					cellValue = cell.getStringCellValue().trim();
				}
					break;

				default:
					break;
				}
			}
		} catch (Exception e) {
			throw new AppBizException(99, e.getMessage());
		}
		return cellValue;
	}

	public boolean getTimeDate(String date) {
		String eL = "[0-9]{4}-[0-9]{2}";
		Pattern p = Pattern.compile(eL);
		Matcher m = p.matcher(date);
		boolean dateFlag = m.matches();
		if (!dateFlag) {
			return false;
		}
		return true;
	}

	public boolean getLimtDate(String date) {
		if (date.length() < 7) {
			return false;
		}
		String month = date.substring(5, 7);
		if (Integer.parseInt(month) > 12 || Integer.parseInt(month) <= 0) {
			return false;
		}
		return true;
	}

}
